import pandas as pd

def first_demo():
    mydataset = {
        'sites': ["Google", "Runoob", "Wiki"],
        'number': [1, 2, 3]
    }
    data = pd.DataFrame(mydataset)
    print(data)

# 创建 简单的 Series 实例：
def parse_series():
    a = [1,2,3,4,5,6,7]
    s = pd.Series(a)
    # dtype: int64  (数据类型)
    print("创建的series: ")
    print(s)

    # 更改 索引
    s2 = pd.Series(a,index=['a','b','c','d','e','f','g'])
    print("更改后索引的 series 数据：")
    print(s2)

    print("获取series 索引数据:",s2['d'])
    # 只需要指定需要数据的索引即可(  筛选某个范围的数据  )
    print(s2['c':'d'])

# 我们也可以使用 key/value 对象，类似字典来创建 Series：
def create_series():
    sites = {1: "Google", 2: "Runoob", 3: "Wiki"}
    res = pd.Series(sites,index=[1,3])
    print(res)
    # 设置 Series 名称参数：
    res2 = pd.Series(sites,index=[1,3],name="Google-test")
    print(res2)






if __name__ == "__main__":
    # first_demo()
    # parse_series()
    create_series()